// src/api/textToSpeechAPI.ts

import { request } from "../request";

const textToSpeechAPI = async (input: string) => {
    return request("https://api.siliconflow.cn/v1/audio/speech", {
        method: "post",
        headers: {
            Authorization: "Bearer sk-lghnjmlspvtlhfhnbamhymohfztxbzhmcylqujcgbviiecaz", // 替换成真实 token
            "Content-Type": "application/json",
        },
        data: {
            model: "FunAudioLLM/CosyVoice2-0.5B",
            input: `Can you say it with a happy emotion? <|endofprompt|>${input}`,
            voice: "FunAudioLLM/CosyVoice2-0.5B:alex",
        },
        responseType: 'arraybuffer', // 指定响应类型为ArrayBuffer以处理二进制音频数据
    });
};

export default textToSpeechAPI;
